//
//  HRTopicListLayout.m
//  Hear
//
//  Created by mac on 2017/11/29.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRTopicListLayout.h"

@implementation HRTopicListLayout
-(void)setChatModel:(HRFunChatModel *)chatModel{
    _chatModel = chatModel;
    
    
    CGFloat leftPading = 10;
    
    CGFloat backWidth = kFullWidth-leftPading*2;
    
    CGFloat titleLabelHeight= [_chatModel.TopicTitle boundingRectWithSize:CGSizeMake(backWidth-leftPading*2, 0)/*计算高度要先指定宽度*/ options:NSStringDrawingUsesLineFragmentOrigin |
                               NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:CustomUIFont(13)} context:nil].size.height;
    
    _titleLabelRect = CGRectMake(leftPading, leftPading, backWidth-leftPading*2, titleLabelHeight);
    
    if (_chatModel.SoundUrl.length){
        _soundButtonRect = CGRectMake(_titleLabelRect.origin.x, CGRectGetMaxY(_titleLabelRect)+leftPading, backWidth/2, 50);

    }else{
        _soundButtonRect = CGRectMake(_titleLabelRect.origin.x, CGRectGetMaxY(_titleLabelRect), backWidth/2, 0);
    }

    
    _timeLabelRect = CGRectMake(_titleLabelRect.origin.x, CGRectGetMaxY(_soundButtonRect)+leftPading, 70, 20);

    
    _statusLabelRect = CGRectMake(_titleLabelRect.origin.x, CGRectGetMaxY(_timeLabelRect)+leftPading, 60, 20);
    
    _deleteButotnRect = CGRectMake(backWidth-60, _statusLabelRect.origin.y, 50, 20);

    _ageinButtonRect = CGRectMake(_deleteButotnRect.origin.x-60, _deleteButotnRect.origin.y, 50, 20);

    _backViewRect = CGRectMake(leftPading, leftPading, backWidth, CGRectGetMaxY(_ageinButtonRect)+leftPading);

    
    _cellHeight = CGRectGetMaxY(_backViewRect);
}
@end
